﻿using Common;
using MySuperSocketServer.AppSession;
using MySuperSocketServer.RequestInfoParser;
using SuperSocket.SocketBase;
using SuperSocket.SocketBase.Config;
using SuperSocket.SocketBase.Protocol;
using System.Net;
using System.Text;

namespace MySuperSocketServer.AppServer
{
    public class TelnetServer : AppServer<TelnetSession>
    {
        public TelnetServer() : base(new TerminatorReceiveFilterFactory("\r\n",Encoding.UTF8, GetRequestInfoParser()))
        {
        }

        protected override bool Setup(IRootConfig rootConfig, IServerConfig config)
        {
            return base.Setup(rootConfig, config);
        }

        protected override void OnStartup()
        {
            base.OnStartup();
        }

        protected override void OnStopped()
        {
            base.OnStopped();
        }

        #region 私有方法
        /// <summary>
        /// 获取命令行协议
        /// </summary>
        /// <returns></returns>
        private static IRequestInfoParser<StringRequestInfo> GetRequestInfoParser()
        {
            IRequestInfoParser<StringRequestInfo> result = new BasicRequestInfoParser();

            if (AppSettingsHelper.GetConfigBool("IsUseRequestInfoParserNoKeyOneParameter"))
            {
                result = new RequestInfoParserNoKeyOneParameter();
            }

            return result;
        }
        #endregion
    }
}
